﻿using System;
using System.IO;
using System.IO.Compression;
using System.Runtime.Serialization.Formatters.Binary;

namespace ParticlePlayground
{
	// Token: 0x02000143 RID: 323
	public class PlaygroundCompression
	{
		// Token: 0x060006DF RID: 1759 RVA: 0x00028DB8 File Offset: 0x00026FB8
		public static byte[] SerializeAndCompress(object obj)
		{
			byte[] result;
			using (MemoryStream memoryStream = new MemoryStream())
			{
				using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Compress, true))
				{
					BinaryFormatter binaryFormatter = new BinaryFormatter();
					binaryFormatter.Serialize(gzipStream, obj);
				}
				result = memoryStream.ToArray();
			}
			return result;
		}

		// Token: 0x060006E0 RID: 1760 RVA: 0x00028E30 File Offset: 0x00027030
		public static T DecompressAndDeserialize<T>(byte[] data)
		{
			T result;
			using (MemoryStream memoryStream = new MemoryStream(data))
			{
				using (GZipStream gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress, true))
				{
					BinaryFormatter binaryFormatter = new BinaryFormatter();
					result = (T)((object)binaryFormatter.Deserialize(gzipStream));
				}
			}
			return result;
		}
	}
}
